#include "stream_tools.h"

template<
    unsigned WIDTH,
    unsigned N_CH0,
    unsigned N_CH1,
    unsigned VEC_LEN
>
void concat(data_stream<WIDTH>& in0, data_stream<WIDTH>& in1, data_stream<WIDTH>& out)
{
    assert(in0.size() == VEC_LEN * N_CH0);
    assert(in1.size() == VEC_LEN * N_CH1);
    assert(out.empty());

    #pragma HLS DATAFLOW

    for (unsigned i = 0; i < VEC_LEN; ++i) {
        for (unsigned j = 0; j < N_CH0 + N_CH1; ++j) {
            #pragma HLS PIPELINE II=1
            ap_uint<WIDTH> buf;
            if (j < N_CH0) {
                buf = in0.read();
            }
            else {
                buf = in1.read();
            }
            out.write(buf);
        }
    }

    assert(in0.empty());
    assert(in1.empty());
    assert(out.size() == VEC_LEN * (N_CH0 + N_CH1));
    return;
};
